/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "member")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Member1.findAll", query = "SELECT m FROM Member m"),
    @NamedQuery(name = "Member1.findByIdmember", query = "SELECT m FROM Member m WHERE m.idmember = :idmember")})
public class Member implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "idmember")
    private Integer idmember;
    @Lob
    @Size(max = 65535)
    @Column(name = "firstname")
    private String firstname;
    @Lob
    @Size(max = 65535)
    @Column(name = "name")
    private String name;
    @Lob
    @Size(max = 65535)
    @Column(name = "language")
    private String language;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "password")
    private String password;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idmember")
    private Collection<Nfcequipment> nfcequipmentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idmember")
    private Collection<Userequest> userequestCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idmember")
    private Collection<Poi> poiCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idmember")
    private Collection<Route> routeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idmember")
    private Collection<Poicomment> poicommentCollection;

    public Member() {
    }

    public Member(Integer idmember) {
        this.idmember = idmember;
    }

    public Member(Integer idmember, String email, String password) {
        this.idmember = idmember;
        this.email = email;
        this.password = password;
    }

    public Integer getIdmember() {
        return idmember;
    }

    public void setIdmember(Integer idmember) {
        this.idmember = idmember;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @XmlTransient
    public Collection<Nfcequipment> getNfcequipmentCollection() {
        return nfcequipmentCollection;
    }

    public void setNfcequipmentCollection(Collection<Nfcequipment> nfcequipmentCollection) {
        this.nfcequipmentCollection = nfcequipmentCollection;
    }

    @XmlTransient
    public Collection<Userequest> getUserequestCollection() {
        return userequestCollection;
    }

    public void setUserequestCollection(Collection<Userequest> userequestCollection) {
        this.userequestCollection = userequestCollection;
    }

    @XmlTransient
    public Collection<Poi> getPoiCollection() {
        return poiCollection;
    }

    public void setPoiCollection(Collection<Poi> poiCollection) {
        this.poiCollection = poiCollection;
    }

    @XmlTransient
    public Collection<Route> getRouteCollection() {
        return routeCollection;
    }

    public void setRouteCollection(Collection<Route> routeCollection) {
        this.routeCollection = routeCollection;
    }

    @XmlTransient
    public Collection<Poicomment> getPoicommentCollection() {
        return poicommentCollection;
    }

    public void setPoicommentCollection(Collection<Poicomment> poicommentCollection) {
        this.poicommentCollection = poicommentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmember != null ? idmember.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Member)) {
            return false;
        }
        Member other = (Member) object;
        if ((this.idmember == null && other.idmember != null) || (this.idmember != null && !this.idmember.equals(other.idmember))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Member1[ idmember=" + idmember + " ]";
    }

}
